﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class ScrollCircle : ScrollRect , IBeginDragHandler
{

    protected float mRadius = 0f;

	// Use this for initialization
	protected override void Start () {
        base.Start();
        mRadius = (transform as RectTransform).sizeDelta.x * 0.5f;
	}
    
    public override void OnDrag(PointerEventData eventData)
    {
        Debug.Log("开始拖动");
        base.OnDrag(eventData);
        var contentPos = this.content.anchoredPosition;
        if (contentPos.magnitude > mRadius)
        {
            contentPos = contentPos.normalized * mRadius;
            SetContentAnchoredPosition(contentPos);
        }
    }
   
/*
    public void OnBeginDrag(PointerEventData eventData)
    {
        Debug.Log("开始拖动");
        var contentPos = this.content.anchoredPosition;
        if (contentPos.magnitude > mRadius)
        {
            contentPos = contentPos.normalized * mRadius;
            SetContentAnchoredPosition(contentPos);
        }
    }
    public void IEndDragHandler(PointerEventData eventData)
    {
        Debug.Log("结束拖动");
    } */
    
}
